package com.my.study.algorithm.leetcode;

/**
 * 将数组的0移到最后
 * 
 * @author Carlos
 * @version 1.0.0
 * @date 2023/2/23 7:51
 */
public class MoveZeroes {
    
    
    
    public void moveZeroes(int[] nums) {
        int idx = 0;

        for (int num : nums) {
            if (num != 0) {
                nums[idx++] = num;   
            }
        }
        
        while (idx < nums.length) {
            nums[idx++] = 0;
        }
    }
    
}
